package com.senseu.pages;

import com.senseu.base.BasePage;
import io.appium.java_client.AppiumBy;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import java.time.Duration;
import java.util.function.Function;

public class BindStationPage extends BasePage {

    public BindStationPage(AppiumDriver driver) {
        super(driver);
    }

    @FindBy(id = "com.senseu.baby:id/btn_bind")
    private WebElement confirm;

    @FindBy(id = "com.senseu.baby:id/et_wifi_name")
    private WebElement etWifiName;

    @FindBy(id = "com.senseu.baby:id/et_wifi_password")
    private WebElement etWifiPassword;

    public void clickConfirm() {
        confirm.click();
    }


    public void inputWifiAndPwd(String wifiName, String password) {
        etWifiName.clear();
        etWifiName.sendKeys(wifiName);

        etWifiPassword.clear();
        etWifiPassword.sendKeys(password);
    }

    public BasePage startBind() {
        confirm.click();
        // TODO: 2025/7/9 jack wait 等待绑定结果
        boolean renameActivity = isInPage(120,"SenseuDeviceRenameActivity");
        if (renameActivity) {
            // 自动进入修改名称界面
            return new ModifyNamePage(driver);
        } else {
            // 表示超时？或者再等待一段时间
            return this;
        }
    }


}
